package net.tmaize.lockview;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import net.tmaize.lockview.listrner.InputFinshListrner;
import net.tmaize.lockview.view.LockView;
import net.tmaize.lockview.widget.LockViewDialog;

public class MainActivity extends Activity {

    private Button button_main;
    private LockView lockView_main;
    private Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mContext = this;

        initButton_main();

        initLockView_main();
    }


    private void initButton_main() {
        button_main = (Button) findViewById(R.id.button_main_1);
        button_main.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final LockViewDialog dialog = new LockViewDialog(mContext,true);
                dialog.open(new InputFinshListrner() {
                    @Override
                    public void doAfterinput() {
                        Toast.makeText(mContext, dialog.getInput(), Toast.LENGTH_SHORT).show();
                        //dialog.close();
                    }
                });
            }
        });
    }

    private void initLockView_main() {
        lockView_main = (LockView) findViewById(R.id.lockiew_main);
        lockView_main.setInputFinshListrner(new InputFinshListrner() {
            @Override
            public void doAfterinput() {
                Toast.makeText(mContext, lockView_main.getInput(), Toast.LENGTH_SHORT).show();
            }
        });
    }

}
